using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using T2.WebSecurity.Data.Controllers.Interfaces;
using T2.WebSecurity.Data.Entities.Interfaces;
using T2.WebSecurity.Business.Entities.Interfaces;
using T2.WebSecurity.Business.Entities;
using T2.WebSecurity.Business.Builders;
using T2.WebSecurity.Business.Directors.Interface;
using T2.WebSecurity.Business.Entities.Search.Interfaces;

//--Change Management Control - UsersInRoles Director  --**********************
//--Created By: trooks
//--Description: UsersInRoles Director Class
//--Created Date: 03/07/2013 10:48:52
//--*************************************************************

namespace T2.WebSecurity.Business.Directors
{
	public partial class UsersInRoles_Director_biz : IUsersInRoles_director_biz
	{
		
		public List<IUsersInRoles_biz> Construct (IUsersInRoles_biz _param, bool BuildUp, bool BuildDown)
		{
			UsersInRoles_Builder build = new UsersInRoles_Builder();
			List<IUsersInRoles_biz> retVal = build.BuildParts(_param);
			foreach(IUsersInRoles_biz item in retVal)
			{
				item.UserProfile = BuildUserProfile(item, BuildUp, false);
				item.ApplicationRoles = BuildApplicationRoles(item, BuildUp, false);
		}
			return retVal;
		}
		public List<IUsersInRoles_biz> Construct (IUsersInRolesSearch_biz _param, bool BuildUp, bool BuildDown)
		{
			UsersInRoles_Builder build = new UsersInRoles_Builder();
			List<IUsersInRoles_biz> retVal = build.BuildParts(_param);
			foreach(IUsersInRoles_biz item in retVal)
			{
				item.UserProfile = BuildUserProfile(item, BuildUp, false);
				item.ApplicationRoles = BuildApplicationRoles(item, BuildUp, false);
		}
			return retVal;
		}
		private IUserProfile_biz BuildUserProfile(IUsersInRoles_biz _param, bool BuildUp, bool BuildDown)
		{
			IUserProfile_biz retVal = new UserProfile_biz();
			if(BuildUp)
			{
			IUserProfile_biz UserProfileParam = new UserProfile_biz();
			UserProfileParam.Action = "GetOne";
			UserProfileParam.UserId = _param.UserId;
			UserProfile_Builder builder = new UserProfile_Builder();
			retVal = builder.BuildParts(UserProfileParam).First();
			}
			return retVal;
		}
		private IApplicationRoles_biz BuildApplicationRoles(IUsersInRoles_biz _param, bool BuildUp, bool BuildDown)
		{
			IApplicationRoles_biz retVal = new ApplicationRoles_biz();
			if(BuildUp)
			{
			IApplicationRoles_biz ApplicationRolesParam = new ApplicationRoles_biz();
			ApplicationRolesParam.Action = "GetOne";
			ApplicationRolesParam.ApplicationRoleId = _param.ApplicationRoleId;
			ApplicationRoles_Builder builder = new ApplicationRoles_Builder();
			retVal = builder.BuildParts(ApplicationRolesParam).First();
			}
			return retVal;
		}
	}
}